home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / gamma-bros.swf / scripts / __Packages / classes / fx / LifeMeter.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  1.9 KB  |  75 lines

  1. class classes.fx.LifeMeter
  2. {
  3.    var clip;
  4.    var lifeOrig;
  5.    var num;
  6.    var c;
  7.    var lifeTarget;
  8.    var adjusting = false;
  9.    var alpha = 0;
  10.    var Name = "lifeMeter";
  11.    function LifeMeter()
  12.    {
  13.       this.clip = _root.attachMovie("lifeMeter","lifeMeterClip",817880);
  14.       this.clip._x = _root[_root.char].x + 6;
  15.       this.clip._y = _root[_root.char].y - 12;
  16.    }
  17.    function adjust(plifeOrig, pnum)
  18.    {
  19.       this.lifeOrig = plifeOrig;
  20.       this.num = pnum;
  21.       this.adjusting = true;
  22.       this.clip._x = _root[_root.char].x + 6;
  23.       this.clip._y = _root[_root.char].y - 12;
  24.       this.clip._alpha = 120;
  25.       this.c = 0;
  26.       this.alpha = 100;
  27.       this.lifeTarget = (this.lifeOrig + this.num) / 100 * 24;
  28.    }
  29.    function main()
  30.    {
  31.       this.clip._alpha = this.alpha;
  32.       this.alpha -= 2;
  33.       if(this.alpha < 0)
  34.       {
  35.          this.alpha = 0;
  36.       }
  37.       else
  38.       {
  39.          this.clip._x = _root[_root.char].x + 6;
  40.          this.clip._y = _root[_root.char].y - 12;
  41.       }
  42.       if(this.adjusting)
  43.       {
  44.          this.c = this.c + 1;
  45.          this.clip._x = _root[_root.char].x + 6;
  46.          this.clip._y = _root[_root.char].y - 12;
  47.          this.alpha = 100;
  48.          if(this.num < 0)
  49.          {
  50.             this.clip.bar._width -= 1;
  51.             if(this.clip.bar._width <= this.lifeTarget)
  52.             {
  53.                this.clip.bar._width = this.lifeTarget;
  54.             }
  55.          }
  56.          else
  57.          {
  58.             this.clip.bar._width += 1;
  59.             if(this.clip.bar._width >= this.lifeTarget)
  60.             {
  61.                this.clip.bar._width = this.lifeTarget;
  62.             }
  63.          }
  64.          if(this.c == 45)
  65.          {
  66.             _root[_root.char].inv = false;
  67.          }
  68.          if(this.c == 60)
  69.          {
  70.             this.adjusting = false;
  71.          }
  72.       }
  73.    }
  74. }
  75.